﻿Public Class DataListMenu4
    Inherits System.Web.UI.Page

  
    Protected mDtPermissoes As DataTable

    Protected Sub EncheMenu()
        Try
            Me.BuscaPermissoesUsuarioNoPortal()
            Me.EncheMenuPerfil()

        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BuscaPermissoesUsuarioNoPortal()
        'Dim obj As New ORMAdminDLL.clsORMTipoPerfilUsuarios()
        'Try
        '    Dim PerfilNomePortalPermissao As String = "SaudeFOZ"
        '    mDtPermissoes = obj.BuscaPermissoesUsuarioNoPortal(764, PerfilNomePortalPermissao)
        'Finally
        '    obj.Dispose()
        '    obj = Nothing
        'End Try
    End Sub

    Private Sub EncheMenuPerfil()

        Dim Aux As Integer = 0
        Me.divMenuLista.InnerHtml = "<ul class='listaPerfil'>"
        For Each dtRow As DataRow In Me.mDtPermissoes.Rows()
            If CInt(dtRow("TipoPerfilId")) <> Aux Then
                Me.divMenuLista.InnerHtml &= "<li><a class='lnkMostraMenu'>" & dtRow("TipPerfNome").ToString & "</a>"
                Me.divMenuLista.InnerHtml &= "<div class='tooltip'>"
                Me.divMenuLista.InnerHtml &= "<div class='tooltiptopo'></div>"
                Me.divMenuLista.InnerHtml &= "<div class='tooltipcontent'>"
                Me.EncheMenuTipoFormulario(CInt(dtRow("TipoPerfilId")))
                Me.divMenuLista.InnerHtml &= "</div></div>"
                Me.divMenuLista.InnerHtml &= "</li>"
                Aux = CInt(dtRow("TipoPerfilId"))
            End If
        Next
        Me.divMenuLista.InnerHtml &= "</ul>"

    End Sub

    Private Sub EncheMenuTipoFormulario(ByVal tipoPerfilID As Integer)

        Me.divMenuLista.InnerHtml &= "<ul class='listaTipoForm'>"
        Dim Aux As String = ""
        For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & tipoPerfilID)
            If dtRow("FormTipo") <> Aux Then
                Me.divMenuLista.InnerHtml &= "<li><span>" & dtRow("FormTipo") & "</span>"
                Me.EncheMenuFormularios(tipoPerfilID, dtRow("FormTipo").ToString)
                Me.divMenuLista.InnerHtml &= "</li>"
                Aux = dtRow("FormTipo")
            End If
        Next
        Me.divMenuLista.InnerHtml &= "</ul>"

    End Sub

    Private Sub EncheMenuFormularios(ByVal tipoPerfilID As Integer, ByVal formNome As String)

        Me.divMenuLista.InnerHtml &= "<ul class='listaForm'>"
        Dim Aux As Integer = 0
        For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & tipoPerfilID & " AND FormTipo = '" & formNome & "'")
            If CInt(dtRow("FormularioID")) <> Aux Then
                Me.divMenuLista.InnerHtml &= "<li><a href='" & dtRow("PageEndereco") & "'>" & dtRow("FormNmMenu") & "</a></li>"
                Aux = CInt(dtRow("FormularioID"))
            End If
        Next
        Me.divMenuLista.InnerHtml &= "</ul>"

    End Sub

    Protected Sub uia_Click(ByVal sender As Object, ByVal e As EventArgs) Handles uia.Click
        Me.EncheMenu()
    End Sub

End Class